package com.liukuo;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import com.liukuo.model.User;

public class Login extends Activity
{
    private EditText usernameField,passwordField;
    private Button logBtn;
    private User user;
    private ProgressDialog progressDialog;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.login);
        Resources.getSystem();
        usernameField = (EditText)findViewById(R.id.username_field);
        passwordField = (EditText)findViewById(R.id.password_field);
        logBtn = (Button)findViewById(R.id.logBtn);
        user = new User();
        logBtn.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                 user.username = usernameField.getText().toString();
                user.password = passwordField.getText().toString();
                if(user.username.length() == 0 || user.password.length() == 0){
                    new AlertDialog.Builder(Login.this).setMessage("用户名和密码都不能为空！").setPositiveButton("ok",null);
                }else {
                    doLogin();
                }
            }
        });
    }
    
    public void doLogin(){
        progressDialog = progressDialog.show(Login.this,"请稍候...","陈芳正在打牌！",true);

        progressDialog.dismiss();
    }
}
